package com.ruoyi.web.controller.dir;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.dir.domain.dto.DirWordDto;
import com.ruoyi.dir.service.DirWordService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.dir.domain.DirWord;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 彝文Controller
 * 
 * @author ljsy
 * @date 2023-03-11
 */
@RestController
@RequestMapping("/system/word")
public class DirWordController extends BaseController
{
    @Autowired
    private DirWordService dirWordService;

    /**
     * 查询彝文列表
     */
    @PreAuthorize("@ss.hasPermi('system:word:list')")
    @GetMapping("/list")
    public TableDataInfo list(DirWord dirWord)
    {
        startPage();
        List<DirWordDto> list = dirWordService.selectDirWordList(dirWord);
        return getDataTable(list);
    }

    /**
     * 获取彝文详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:word:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dirWordService.selectDirWordById(id));
    }

    /**
     * 新增彝文
     */
    @PreAuthorize("@ss.hasPermi('system:word:add')")
    @Log(title = "彝文", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DirWord dirWord)
    {
        return toAjax(dirWordService.insertDirWord(dirWord));
    }

    /**
     * 修改彝文
     */
    @PreAuthorize("@ss.hasPermi('system:word:edit')")
    @Log(title = "彝文", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DirWord dirWord)
    {
        return toAjax(dirWordService.updateDirWord(dirWord));
    }

    /**
     * 删除彝文
     */
    @PreAuthorize("@ss.hasPermi('system:word:remove')")
    @Log(title = "彝文", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dirWordService.deleteDirWordByIds(ids));
    }
}
